package com.dataknife.cases;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.dataknife.api.InsertBuilder;
import com.dataknife.util.URLParser;

public class ReferenceInsertBuilder extends InsertBuilder
{
  
  @Override
  public List<String> buildInsertSqls(List<Map<String, Object>> selectResult)
  {
    List<String> sqls = new ArrayList<String>();
    for (Map<String, Object> map : selectResult) {
      StringBuffer sql = new StringBuffer("insert into DAY_REFERER(id,app_id,URL,Type,day_time,pv,uv) values ( ");
      sql.append("'"+UUID.randomUUID()+"',");
      sql.append("'"+map.get("APP_ID")+"',");
      sql.append("'"+map.get("URL")+"',");
      sql.append("'"+URLParser.parse(map.get("URL").toString())+"',");
      sql.append("'"+map.get("DAY_TIME")+"',");
      sql.append("'"+map.get("PV")+"',");
      sql.append("'"+map.get("UV")+"')");
      sqls.add(sql.toString());
    }
    return sqls;
  }

}
